package goActorsCommon

import (
	"os"
)

// Naming is the interface that wraps the basic naming methods (Resolve, Register, UnRegister).
type Naming interface {
	// If the object knows the Pid for that name, returns the Pid object.
	// Else returns an error.
	Resolve ( name * NameWrap, result * PidWrap ) os.Error
	// Try's to register that Pid as the given name.
	// Returns an error if the name is already in use.
	Register ( args * RegisterArgsWrap, res * bool ) os.Error
	// Try's to remove the association between that name and a Pid object.
	// Returns an error if that name isn't registered.
	UnRegister ( name * NameWrap ) os.Error
}

// Wrap for a Pid object.
type PidWrap struct {
	RealPid	Pid
}

func New_PidWrap ( pid Pid ) * PidWrap {
	return &PidWrap { pid }
}

// Wrap for the name argument of the Resolve and Register functions.
type NameWrap struct {
	RealName	string
}

func New_NameWrap ( name string ) * NameWrap {
	return &NameWrap { name }
}

// Wrap for the argument of the Register function.
type RegisterArgsWrap struct {
	RealName	string
	RealPid		Pid
}

func New_RegisterArgsWrap ( name string, pid Pid ) * RegisterArgsWrap {
	return &RegisterArgsWrap { name, pid }
}

// Wrap for an int.
type IntWrap struct {
	RealInt		int
}

func New_IntWrap ( realInt int ) * IntWrap {
	return &IntWrap { realInt }
}

const (
	Successor 	= 0
	Predecessor	= 1
)

